<ui:fragment xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

	<h:form styleClass="form-horizontal">
		<fieldset>
			<legend>
				<h3>
					<h:outputText value="#{msg['label.mercadoria']}" />
					<small> <h:outputText value="#{subtitle}" /></small>
				</h3>
			</legend>
			<div class="control-group">
				<label class="control-label"><h:outputText
						value="#{msg['label.mercadoria.nome']}" /></label>
				<div class="controls">
					<h:inputText value="#{mercadoriaMB.mercadoria.nome}"
						label="#{msg['label.mercadoria.nome']}" required="true"
						styleClass="input-large">						
					</h:inputText>
				</div>
			</div>

			<div class="control-group">
				<label class="control-label"><h:outputText
						value="#{msg['label.mercadoria.descricao']}" /></label>
				<div class="controls">
					<h:inputText value="#{mercadoriaMB.mercadoria.descricao}"
						label="#{msg['label.mercadoria.descricao']}" required="true"
						styleClass="input-large">						
					</h:inputText>
				</div>
			</div>

			<div class="control-group">
				<label class="control-label"><h:outputText
						value="#{msg['label.mercadoria.quantidade']}" /></label>
				<div class="controls">
					<h:inputText value="#{mercadoriaMB.mercadoria.quantidade}"
						label="#{msg['label.mercadoria.quantidade']}" required="true"
						styleClass="input-small">
					</h:inputText>
				</div>
			</div>

			<div class="control-group">
				<label class="control-label"><h:outputText
						value="#{msg['label.mercadoria.preco']}" /></label>
				<div class="controls">
					<h:inputText value="#{mercadoriaMB.mercadoria.preco}"
						label="#{msg['label.mercadoria.preco']}" required="true"
						styleClass="input-small">					
					</h:inputText>
				</div>
			</div>
		</fieldset>

		<div class="control-group">
			<div class="controls">
				<p:commandButton value="#{msg['button.salvar']}"
					action="#{mercadoriaMB.salvar}" styleClass="btn btn-success" onclick="dlg.show();" oncomplete="dlg.hide();"
					rendered="#{mercadoriaMB.mercadoria != null}" />
				<p:button value="#{msg['button.cancelar']}"
					outcome="listaMercadorias" styleClass="btn" />
				<p:commandButton value="#{msg['button.excluir']}"
					onclick="confirmation.show()"
					rendered="#{mercadoriaMB.mercadoria.id != null}" immediate="true"
					styleClass="btn btn-danger" />
			</div>
		</div>
		
		<p:dialog id="dialog" header="#{msg['dialog.emexecucao.titulo']}" widgetVar="dlg" dynamic="true" modal="true">  
	    	<h:outputText value="#{msg['dialog.emexecucao.aguarde']}" />  
		</p:dialog>
		
		<p:confirmDialog id="confirmDialog" message="#{msg['excluir.mercadoria.confirma']}"
			header="#{msg['excluir.mercadoria']}" severity="alert" widgetVar="confirmation">  
	        <p:commandButton id="confirm" value="#{msg['confirma.sim']}" update="messages" 
	        	oncomplete="confirmation.hide()" action="#{mercadoriaMB.remover}" />  
	        <p:commandButton id="decline" value="#{msg['confirma.nao']}" 
	        	onclick="confirmation.hide()" type="button" />
	    </p:confirmDialog>
	
		<p:messages id="messages" showDetail="false" autoUpdate="true" closable="true" />
		<!-- <h:inputHidden value="#{mercadoriaMB.mercadoria.id}" /> -->
	</h:form>
</ui:fragment>